// NOTE ES5代码
/**
 * 浩天云项目中部分组件
 * @authors 马少博 (you@example.org)
 * @date    2017-08-09 14:22:29
 * @version 1.0
 */

//NOTE此处应该为通用方法

var _Vue$component;

function _defineProperty(obj, key, value) {
	if(key in obj) {
		Object.defineProperty(obj, key, {
			value: value,
			enumerable: true,
			configurable: true,
			writable: true
		});
	} else {
		obj[key] = value;
	}
	return obj;
}

function _broadcast(componentName, eventName, params) {
	this.$children.forEach(function(child) {
		var name = child.$options.componentName;
		if(name === componentName) {
			child.$emit.apply(child, [eventName].concat(params));
		} else {
			_broadcast.apply(child, [componentName, eventName].concat([params]));
		}
	});
}
// 　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　
// 　◆◆◆◆◆　　　◆　　　◆◆◆◆　　◆◆◆　　　◆◆◆◆◆　
// 　◆　◆　◆　　　◆　　　　◆　　◆　　◆　　　　　◆　　◆　
// 　　　◆　　　　　◆◆　　　◆　　◆　　◆　　　　　◆　◆　　
// 　　　◆　　　　◆　◆　　　◆◆◆　　　◆　　　　　◆◆◆　　
// 　　　◆　　　　◆　◆　　　◆　　◆　　◆　　　　　◆　◆　　
// 　　　◆　　　　◆◆◆◆　　◆　　◆　　◆　　　　　◆　　　　
// 　　　◆　　　　◆　　◆　　◆　　◆　　◆　　　◆　◆　　◆　
// 　　◆◆◆　　◆◆　　◆◆◆◆◆◆　　◆◆◆◆◆◆◆◆◆◆◆　
//表格组件
//表格组件
Vue.component('ht-table', {
			template: "<div>" +
				"        <table class=\"table table-hover\">" +
				"          <thead>" + "            <tr>" +
				"              <!-- 展示序列号 -->" + "              <th v-show=\"!!showindex\">#</th>" + "              <!-- 遍历当前的列名，进行展示，同时设置列的style样式 -->" + "              <th v-for=\"x in rule\" :width=\"x.width\" :style=\"{textAlign:x.align,width:x.width}\"  :class=\"x.class\">{{x.name}}</th>" + "            </tr>" + "          </thead>" + "          <tbody>" + "            <!-- 搜索结果进行处理 -->" + "            <tr v-for=\"(x,index) in valuelist\" v-show=\"!showLoading&&valuelist!=null&&valuelist.length>0\">" + "              <td v-show=\"!!showindex\">{{index+1}}</td>" + "              <td v-for=\"y in rule\" :style=\"{textAlign:y.align,width:y.width}\">" + "                <!--Begin: If当前的参数为多参数，进行多参数处理操作 -->" + "                <span v-if=\"y.dataKey.split(\',\').length>1\"> " + "                  <!--NOTE 此处的逻辑有点不正常，难描述。" + "                    每个td中的params参数，先置为空数组，再往数组中逐个添加当前td中的参数。" + "                    目的是防止其他td中多参数与当前td参数拼接到一起 -->" + "                <span v-show=\'false\'>{{x.params=[]}}</span>" + "                <span v-for=\"singleKey in y.dataKey.split(\',\')\" style=\"display:none;\"> " + "                        {{x.params.push(x[singleKey])}}" + "                    </span>" + "                <span v-html=\"render(x.params,y.filter)\"> </span>" + "                </span>" + "                <!-- End:结束多参数判断 -->" + "                <!-- Else当前的参数为单个参数，直接进行处理 -->" + "                <span v-else v-html=\"render(x[y.dataKey],y.filter)\"> </span>" + "              </td>" + "            </tr>" + "            <!-- 当前搜索结果为空时，提示没有搜索结果 -->" + "            <tr v-show=\"!showLoading&&(valuelist==null||valuelist.length==0)\">" + "              <td colspan=\"100\">" + "                <h2 class=\"text-center\" style=\"color:#a78989;\">暂无结果</h2>" + "              </td>" + "            </tr>" + "          </tbody>" + "        </table>" + "        <!-- 加载动画区域 NOTE: 通过修改样式 .cssload-loader 相关参数可以更改动画-->" + "        <div v-show=\"showLoading\" :style=\"loadingHeight\" class=\"relative\">" + "          <div class=\"cssload-clock\"></div>" + "        </div>" + "        <!-- 分页控件模块 -->" + "        <div class=\"pull-right page\">" + "          <ul class=\"pagination\" v-show=\"valuelist!=null&&valuelist.length>0\"></ul>" + "        </div>" + "        <!-- 显示信息模块 -->" + "        <div class=\"pull-left infos\" v-show=\"showword\">" + "          <span class=\"infos\" v-show=\"valuelist!=null&&valuelist.length>0\">每页显示<b>{{pageSize}}</b>条数据,共<b>{{rowCount}}</b>条数据</span>" + "        </div>" + "        <!-- 搜索参数 -->" + "        <span style=\"display:none;\">{{searchDatas}}</span>" + "      </div>",
			props: {
				ajaxurl: {
					required: true
				},
				searchData: {
					default: function _default() {
						return {
							currentPage: 1
						};
					}
				},
				showindex: {
					default: true
				},
				showword: {
					default: true
				}
			},
			data: function data() {
				return {
					valuelist: [],
					rule: [],
					nameurl: "李三丰",
					showLoading: false,
					loadingHeight: "height:300px",
					rowCount: 0, //总行数
					pageSize: 0 //每页显示条数

				};
			},
			filter: {
				toGender: function toGender(value) {
					return value == "M" ? "男" : "女";
				}
			},
			methods: {
				toshow: function toshow(e) {
					e.preventDefault();
					this.$emit("chuandi");
				},
				//异步请求数据
				getlist: function getlist() {
					var self = this;
					var params = new Object();
					params = self.searchData;
					var pageindex = params.currentPage;
					self.loadingHeight = $(self.$el).find('tbody').height() ? "height:" + (($(self.$el).find('tbody').height() - 0 > 300 ? $(self.$el).find('tbody').height() : 300) + "px") : "height:300px";
					$.ajax({
								type: "POST",
								url: this.ajaxurl,
								beforeSend: function beforeSend(request) {
									self.showLoading = true;
								},
								data: params,
								dataType: "json",
								success: function success(data) {
									if(data != null && data != "") {
										try {
											self.valuelist = [{
													"cake_id": "添加公告“12”",
													"cake_name": "2017-12-22 14:29:48",
													"picture": "通用平台",
													"score_change": "通用平台",
													"account": "1",
													"out_price": "超级管理员"
												}, {
													"cake_id": "添加公告“222”",
													"cake_name": "2017-12-22 14:29:43",
													"picture": "天津研发部",
													"score_change": "通用平台",
													"account": "3",
													"out_price": "张三"
												}, {
													"cake_id": "添加公告“2”",
													"cake_name": "2017-12-22 14:29:39",
													"picture": "天津研发部",
													"score_change": "通用平台",
													"account": "4",
													"out_price": "李四"
												}, {
													"cake_id": "添加公告“11111”",
													"cake_name": "2017-12-22 14:29:35",
													"picture": "通用平台",
													"score_change": "通用平台",
													"account": "1",
													"out_price": "超级管理员"
												}, {
													"cake_id": "添加公告“111”",
													"cake_name": "2017-12-22 14:29:30",
													"picture": "通用平台",
													"score_change": "通用平台",
													"account": "1",
													"out_price": "超级管理员"
												}, {
													"cake_id": "添加公告“11”",
													"cake_name": "2017-12-22 14:29:26",
													"picture": "通用平台",
													"score_change": "通用平台",
													"account": "1",
													"out_price": "超级管理员"
												}];
												self.rowCount = 6;
												self.pageSize = 10;
													console.log(self.valuelist.length);
												for(var i = 0; i < self.valuelist.length; i++) {
													var element = self.valuelist[i];
													element["params"] = [];
												}
												// BootStrap分页控件的声明
											 	if(self.valuelist.length > 0) {
													var $page = $(self.$el.children[2]).find("ul");
													self.initPageDiv($page, 1,1, 5, $page, function() {
														self.searchData.currentPage = 1;
															
													});
												}
											}
											catch(error) {
												self.showLoading = false;
											}
										}
									},
									error: function error(response) {
											self.valuelist = [];
											if(response.responseText && JSON.parse(response.responseText) && JSON.parse(response.responseText).errorMessage) {} else {}
										},
										complete: function complete() {
											self.showLoading = false;
										}
								});
						},
						render: function render(tdData, rule) {
							if(!rule) {
								return tdData;
							} else {
								var filter = rule;
								return window.HtmlFun && window.HtmlFun[filter] ? Object.prototype.toString.call(tdData) == '[object Array]' ? window.HtmlFun[filter].apply(this, tdData) : window.HtmlFun[filter](tdData) : tdData;
							}
						},
						// 分页方法初始化
						initPageDiv: function initPageDiv($dom, now, all, each, $dom2, change) {
							if(parseInt(now) > parseInt(all)) {
								return;
							}
							each = each >= 10 ? 5 : each - 0;
							each = each <= 3 ? 3 : each - 0;
							var options = {
								currentPage: now - 0, // 当前页
								pages: all - 0, // 共几页
								displayedPages: each, // 每次显示几页
								edges: 1,
								onPageClick: function onPageClick(page, event) {
									$dom2.data("page", page);
									change();
								}
							};
							$dom.pagination(options);
						},
						parseText: function parseText(str) {
							if(str.indexOf(0) == "{" || str.indexOf(0) == "[") {
								str = str.replace(/'/g, "\"");
								str = str.replace(/(\s?\{\s?)(\S)/g, "$1" + "\"" + "$2");
								str = str.replace(/(\s?,\s?)(\S)/g, "$1" + "\"" + "$2");
								str = str.replace(/(\S\s?):(\s?\S)/g, "$1" + "\":" + "$2");
								str = str.replace(/,"\{/g, ",{");
								str = str.replace(/""/g, "\"");
								str = str.replace(/\s/g, "");
								try {
									str = JSON.parse(str);
								} catch(e) {}
							}
							return str;
						}
				},
				computed: {
					searchDatas: function searchDatas() {
						this.getlist(0);
						return this.searchData;
					}

				},
				watch: {
					ajaxurl: function(val) {
						this.getlist(0);
					}
				},
				//在组件加载完成后的钩子
				mounted: function mounted() {
					var self = this;
					var _this = this;
					_this.$slots.default.forEach(function(child) {
						var obj = {};
						for(var p in child.componentOptions.propsData) {
							obj[p] = child.componentOptions.propsData[p];
						}
						_this.rule.push(obj);
					});
				}
			});

		/**
		 * table下 column组件声明
		 * 2017年8月4日14:56:51 添加
		 */
		Vue.component('column', {
			template: '<span style="display: none">123</span>',
			props: {
				dataKey: {
					type: String,
					required: true
				},
				name: {
					type: String,
					required: true
				},
				align: {
					type: String,
					default: 'left'
				},
				filter: [String, Array],
				style: String,
				width: String,
				action: [String, Array, Object]
			},
			data: function data() {
				return {};
			},
			mounted: function mounted() {
				// 把{key:1}变成object
				var filter = this.filter;
				if(filter && !$.isPlainObject(filter)) {
					this.filter = this.parseText(filter);
				}
				var action = this.action;
				if(action && !$.isPlainObject(action)) {
					this.action = this.parseText(action);
					if($.isPlainObject(this.action)) {
						this.action = [this.action];
					}
				}
			}
		});
		// 　◆◆◆◆◆　◆◆　◆◆◆◆◆◆◆　　◆◆　　◆◆◆◆◆◆◆　
		// 　　　◆　　　　◆　　◆　　◆　　◆　　◆　　◆　◆　◆　◆　
		// 　　　◆　　　　◆◆　◆　　◆　　◆　　◆　　◆　　　◆　　　
		// 　　　◆　　　　◆◆　◆　　◆◆◆　　　◆　　◆　　　◆　　　
		// 　　　◆　　　　◆　◆◆　　◆　　　　　◆　　◆　　　◆　　　
		// 　　　◆　　　　◆　◆◆　　◆　　　　　◆　　◆　　　◆　　　
		// 　　　◆　　　　◆　　◆　　◆　　　　　◆　　◆　　　◆　　　
		// 　◆◆◆◆◆　◆◆◆　◆　◆◆◆　　　　　◆◆　　　◆◆◆　　　
		//输入框组件
		Vue.component('ht-input', {
			// template: '#ht-input',
			template: '<label style="padding: 0;border: none;border-radius: 0;box-shadow:none;">' + '        <div :class="[' + '                      type === \'textarea\' ? \'el-textarea\' : \'el-input\',' + '                      size ? \'el-input--\' + size : \'\',' + '                      {' + '                        \'is-disabled\': disabled,' + '                        \'el-input-group\': $slots.prepend || $slots.append,' + '                        \'el-input-group--append\': $slots.append,' + '                        \'el-input-group--prepend\': $slots.prepend' + '                      }' + '                    ]">' + '      <template v-if="type !== \'textarea\'">' + '      <!-- 前置元素 -->' + '      <div class="el-input-group__prepend" v-if="$slots.prepend">' + '        <slot name="prepend"></slot>' + '      </div>' + '      <!-- input 图标 -->' + '      <slot name="icon">' + '        <i class="el-input__icon"' + '          :class="[' + '            \'el-icon-\' + icon,' + '            onIconClick ? \'is-clickable\' : \'\'' + '          ]"' + '          v-if="icon"' + '          @click="handleIconClick">' + '        </i>' + '      </slot>' + '      <input' + '        v-if="type !== \'textarea\'"' +
				// NOTE 为了和Bootstrap风格保持一致,取消使用.el-input__inner  
				'        class="form-control"' + '        v-bind="$props" ' + '        :placeholder="places"' + '        :autocomplete="autoComplete"' + '        :value="currentValue"' + '        ref="input"' + '        @input="handleInput"' + '        @focus="handleFocus"' + '        @blur="handleBlur"' + '      >' + '      <i class="el-input__icon el-icon-loading" v-if="validating"></i>' + '      <!-- 后置元素 -->' + '      <div class="el-input-group__append" v-if="$slots.append">' + '        <slot name="append"></slot>' + '      </div>' + '    </template>' + '    </div>' + '    </label>',
			//对外获取的数据
			props: {
				value: [String, Number],
				placeholder: String,
				size: String,
				resize: String,
				readonly: Boolean,
				autofocus: Boolean,
				icon: String,
				disabled: Boolean,
				type: {
					type: String,
					default: 'text'
				},
				name: String,
				autosize: {
					type: [Boolean, Object],
					default: false
				},
				rows: {
					type: Number,
					default: 2
				},
				autoComplete: {
					type: String,
					default: 'off'
				},
				form: String,
				maxlength: Number,
				minlength: Number,
				max: {},
				min: {},
				step: {},
				validateEvent: {
					type: Boolean,
					default: true
				},
				onIconClick: Function
			},
			//
			computed: {
				validating: function validating() {
					return this.$parent.validateState === 'validating';
				},
				textareaStyle: function textareaStyle() {
					return merge({}, this.textareaCalcStyle, {
						resize: this.resize
					});
				}
			},
			watch: {
				'value': function value(_value, oldValue) {
					//根据不同的类型进行处理操作
					var type = this.type;
					switch(type) {
						case "text":
							break;
						case "numbers":
							// this.placeholder = "请输入大于0的整数";
							var reg = new RegExp(/^[1-9]+$/);
							if(!reg.test(_value)) {
								if(_value.length == 1) {

									_value = _value.replace(/[^1-9]/g, '');
								} else {
									if(_value - 0 == 0) {
										_value = "";
									}
									_value = _value.replace(/\D/g, '');
								}
							}
							break;
						case "money":
							// $(".vipprices").keyup(function() {
							var reg = _value.match(/\d+\.?\d{0,2}/);
							var txt = '';
							if(reg != null) {
								txt = reg[0];
							}
							_value = txt;
							// }).change(function() {
							//   $(this).keypress();
							//   var v = $(this).val();
							//   if (/\.$/.test(v)) {
							//     $(this).val(v.substr(0, v.length - 1));
							//   }
							// });
							break;

						default:
							break;
					}
					this.setCurrentValue(_value);
				}
			},

			methods: {
				dispatch: function dispatch(componentName, eventName, params) {
					var parent = this.$parent || this.$root;
					var name = parent.$options.componentName;
					while(parent && (!name || name !== componentName)) {
						parent = parent.$parent;

						if(parent) {
							name = parent.$options.componentName;
						}
					}
					if(parent) {
						parent.$emit.apply(parent, [eventName].concat(params));
					}
				},
				broadcast: function(_broadcast2) {
					function broadcast(_x, _x2, _x3) {
						return _broadcast2.apply(this, arguments);
					}

					broadcast.toString = function() {
						return _broadcast2.toString();
					};

					return broadcast;
				}(function(componentName, eventName, params) {
					broadcast.call(this, componentName, eventName, params);
				}),
				handleBlur: function handleBlur(event) {
					this.$emit('blur', event);
					if(this.validateEvent) {
						this.dispatch('ElFormItem', 'el.form.blur', [this.currentValue]);
					}
				},
				inputSelect: function inputSelect() {
					this.$refs.input.select();
				},
				handleFocus: function handleFocus(event) {
					this.$emit('focus', event);
				},
				handleInput: function handleInput(event) {
					var value = event.target.value;
					this.$emit('input', value);
					this.setCurrentValue(value);
					this.$emit('change', value);
				},
				handleIconClick: function handleIconClick(event) {
					if(this.onIconClick) {
						this.onIconClick(event);
					}
					this.$emit('click', event);
				},
				setCurrentValue: function setCurrentValue(value) {
					if(value === this.currentValue) return;
					this.currentValue = value;
					if(this.validateEvent) {
						this.dispatch('ElFormItem', 'el.form.change', [value]);
					}
				}
			},
			//组件内数据部分
			data: function data() {

				var placehs = "";

				if(this.placeholder == undefined) {

					if(this.type == "numbers") {
						placehs = "请输入数字";
					}
				} else {
					placehs = this.placeholder;
				}

				return {
					currentValue: this.value,
					textareaCalcStyle: {},
					places: placehs
				};
			},
			created: function created() {
				this.$on('inputSelect', this.inputSelect);
				if(this.type == "numbers") {
					if(this.placeholder == undefined) {
						this.places = "请输入大于0的整数";
					}
				}
				if(this.type == "money") {
					if(this.placeholder == undefined) {
						this.places = "请输入金额，小数点后保留两位小数";
					}
				}
			},
			mounted: function mounted() {
				//这个地方我想设置默认的placeholder  但是在添加两个判断条件之后 就会报错  暂时不确定原因
				if(this.type == "numbers") {

					// if (this.placeholder == undefined) {
					// this.placeholder = "请输入数字"
					// }
				}
			}
		});
		// 　◆◆◆◆　　　　◆　　　◆◆◆◆　　◆◆◆◆◆　　◆◆◆　　
		// 　　◆　　◆　　　◆　　　　◆　　◆　　　◆　　　◆　　　◆　
		// 　　◆　　◆　　　◆◆　　　◆　　◆　　　◆　　　◆　　　◆　
		// 　　◆◆◆　　　◆　◆　　　◆　　◆　　　◆　　　◆　　　◆　
		// 　　◆　◆　　　◆　◆　　　◆　　◆　　　◆　　　◆　　　◆　
		// 　　◆　　◆　　◆◆◆◆　　◆　　◆　　　◆　　　◆　　　◆　
		// 　　◆　　◆　　◆　　◆　　◆　　◆　　　◆　　　◆　　　◆　
		// 　◆◆◆　◆◆◆◆　　◆◆◆◆◆◆　　◆◆◆◆◆　　◆◆◆　　

		Vue.component("ht-radio", {
			template: '<label class="el-radio">' + '    <span class="el-radio__input"' + '      :class="{' + '        \'is-disabled\': isDisabled,' + '        \'is-checked\': model === label,' + '        \'is-focus\': focus' + '      }"' + '    >' + '      <span class="el-radio__inner"></span>' + '      <input' + '        class="el-radio__original"' + '        :value="label"' + '        type="radio"' + '        v-model="model"' + '        @focus="focus = true"' + '        @blur="focus = false"' + '        @click="click()"' + '        @change="change()"' + '        :name="name"' + '        :disabled="isDisabled">' + '    </span>' + '    <span class="el-radio__label">' + '      <slot></slot>' + '      <template v-if="!$slots.default">{{label}}</template>' + '    </span>' + '  </label>',
			methods: {
				dispatch: function dispatch(componentName, eventName, params) {
					var parent = this.$parent || this.$root;
					var name = parent.$options.componentName;
					while(parent && (!name || name !== componentName)) {
						parent = parent.$parent;

						if(parent) {
							name = parent.$options.componentName;
						}
					}
					if(parent) {
						parent.$emit.apply(parent, [eventName].concat(params));
					}
				},
				broadcast: function broadcast(componentName, eventName, params) {
					_broadcast.call(this, componentName, eventName, params);
				},
				//当下点击
				click: function click() {
					this.$emit('click');
				},
				change: function change() {
					this.$emit('change');
				}
			},

			props: {
				value: {},
				label: {},
				disabled: Boolean,
				name: String
			},
			data: function data() {
				return {
					focus: false
				};
			},

			computed: {
				isGroup: function isGroup() {
					var parent = this.$parent;
					while(parent) {
						if(parent.$options.componentName !== 'ElRadioGroup') {
							parent = parent.$parent;
						} else {
							this._radioGroup = parent;
							return true;
						}
					}
					return false;
				},

				model: {
					get: function get() {
						return this.isGroup ? this._radioGroup.value : this.value;
					},
					set: function set(val) {
						if(this.isGroup) {
							this.dispatch('ElRadioGroup', 'input', [val]);
						} else {
							this.$emit('input', val);
						}
					}
				},

				isDisabled: function isDisabled() {
					return this.isGroup ? this._radioGroup.disabled || this.disabled : this.disabled;
				}
			},
			watch: {
				label: function label(val) {
					alert('23131');
				}
			}
		}); Vue.component('ht-select', {
			template: '<select class="form-control"> <slot></slot> </select>',
			//对外获取的数据
			props: {
				options: {
					type: Object,
					default: function() {
						//NOTE:在prop设置默认值为对象时,需用方法返回值(不能直接设置值)
						return {
							tags: false,
							minimumResultsForSearch: -1
						};
					}
				},
				value: [String, Number],
				search: {
					type: Boolean,
					default: false
				}
			},
			mounted: function() {
				this.bindSelect();
			},
			methods: {
				//马少博 2018年4月11日10:18:37
				//NOTE 此处添加延时执行,是因为slot无法立即添加到DOM结构中时无法进行值绑定,只能通过延时执行等待slot内容传入后进行绑定
				//NOTE 此处如果options异步请求时间过长,会存在无法绑定select2的情况,所以在有异步获取option列表时,利用ref="sltName"  this.$refs.sltName.bindSelect()方法进行重新绑定(暂时解决办法不影响使用,后期优化)
				bindSelect() {
					var _self = this;
					this.options.minimumResultsForSearch = this.search ? 0 : -1;
					this.options.width = this.options.width || "100%"; //此处设置默认为100%的宽度
					setTimeout(() => {
						$(this.$el)
							.select2(this.options)
							.val(this.value)
							.trigger("change")
							.on("change", function() {
								_self.$emit("input", this.value);
							});
					}, 0);

					// setTimeout(function() {
					//   $(_self.$el)
					//     .select2(_self.options)
					//     .val(_self.value)
					//     .trigger("change")
					//     .on("change", function() {
					//       _self.$emit("input", _self.value);
					//     });
					// }, 0);
				}
			},
			watch: {
				value: function(value) {
					// 更新值
					$(this.$el)
						.val(value)
						.trigger("change");
				},
				options: function(options) {
					// 更新设置
					$(this.$el).select2(options);
				}
			},
			destroyed: function() {
				//删除配置
				$(this.$el)
					.off()
					.select2("destroy");
			}
		});

		// Vue.component('ht-select', (_Vue$component = {
		//   props: {
		//     options: {
		//       type: Object,
		//       default: function _default() {
		//         //NOTE:在prop设置默认值为对象时,需用方法返回值(不能直接设置值)
		//         return {
		//           tags: false,
		//           minimumResultsForSearch: -1
		//         };
		//       }
		//     },
		//     value: String
		//   },
		//   template: '<select class="form-control"> <slot></slot> </select>'
		// }, _defineProperty(_Vue$component, "props", {
		//   options: {
		//     type: Object,
		//     default: function _default() {
		//       //NOTE:在prop设置默认值为对象时,需用方法返回值(不能直接设置值)
		//       return {
		//         tags: false,
		//         minimumResultsForSearch: -1
		//       };
		//     }
		//   },
		//   value: String,
		//   search: {
		//     type: Boolean,
		//     default: false
		//   }
		// }), _defineProperty(_Vue$component, "mounted", function mounted() {
		//   var _self = this;
		//   this.options.minimumResultsForSearch = this.search ? 0 : -1;
		//   this.options.width = this.options.width || "100%"; //此处设置默认为100%的宽度
		//   $(this.$el).select2(this.options).val(this.value).trigger("change").on("change", function() {
		//     _self.$emit("input", this.value);
		//   });
		// }), _defineProperty(_Vue$component, "watch", {
		//   value: function value(_value2) {
		//     // 更新值
		//     $(this.$el).val(_value2).trigger("change");
		//   },
		//   options: function options(_options) {
		//     // 更新设置
		//     $(this.$el).select2(_options);
		//   }
		// }), _defineProperty(_Vue$component, "destroyed", function destroyed() {
		//   //删除配置
		//   $(this.$el).off().select2("destroy");
		// }), _Vue$component));

		Vue.component('ht-date', {
			template: " <div class=\"input-group date form_date\" data-date=\"\" data-link-field=\"dtp_input2\"  ref=\"dateInput\"  style=\"width:100%;\">" + "    <input class=\"form-control settime-input\" type=\"text\" v-bind:value=\"setTime\" readonly :placeholder=\"placeholder\" :disabled=\"disabled\" :class=\"{'disabled':disabled}\">" + "    <span class=\"add-on input-group-addon\">" + "      <span class=\"icon-th  glyphicon glyphicon-calendar\"></span>" + "    </span>" + "  </div>",
			//对外获取的数据 
			props: {
				//对外获取的数据
				value: String,
				option: Object,
				minDate: String,
				maxDate: String,
				placeholder: String,
				disabled: [String, Boolean]
			},
			data: function() {
				//组件内数据部分
				return {
					setTime: this.value || "",
					isDisable: this.disabled
				};
			},
			mounted: function() {
				//组件生成时调用
				this.dateDefind();
			},
			methods: {
				dateDefind() {
					var _self = this;
					if(!_self.disabled) {
						var options = _self.option || {
							language: "zh-CN",
							format: "yyyy-mm-dd",
							minView: 2,
							weekStart: 1,
							autoclose: true,
							pickerPosition: "bottom-left"
						};

						$(_self.$refs.dateInput).datetimepicker(options);
						//如果输入的值合法,则设置起始时间
						if(
							_self.minDate &&
							new Date(_self.minDate) != "Invalid Date" &&
							isNaN(_self.minDate)
						) {
							$(_self.$refs.dateInput).datetimepicker("setStartDate", _self.minDate);
						}
						if(
							_self.maxDate &&
							new Date(_self.maxDate) != "Invalid Date" &&
							isNaN(_self.maxDate)
						) {
							$(_self.$refs.dateInput).datetimepicker("setEndDate", _self.maxDate);
						}

						//先移除事件  在重新注册事件,否则会涉及到事件的多次注册
						$(_self.$refs.dateInput)
							.datetimepicker()
							.unbind("hide");
						//选择完毕后通知父组件
						$(_self.$refs.dateInput)
							.datetimepicker()
							.on("hide", function(e) {
								// $nextTick
								_self.$nextTick(() => {
									_self.setTime = $(e.target)
										.find(".settime-input")
										.val();
									_self.$emit(
										"input",
										_self.setTime
									);
									_self.$emit(
										"select",
										_self.setTime
									);
								})
							});
					}
				}
			},
			watch: {
				minDate: function() {
					this.dateDefind();
					if(new Date(this.setTime) < new Date(this.minDate)) {
						this.setTime = this.minDate;
						this.$emit("input", this.minDate);
					}
					return this.minDate;
				},
				maxDate: function() {
					this.dateDefind();
					if(new Date(this.setTime) > new Date(this.maxDate)) {
						this.setTime = this.maxDate;
						this.$emit("input", this.maxDate);
					}
					return this.maxDate;
				},
				value: function() {
					this.setTime = this.value;
				}
			}
		});

		Vue.component('ht-checkbox', {
			template: "<label class=\"el-checkbox\">" + "    <span class=\"el-checkbox__input\" :class=\"{" + "        \'is-disabled\': disabled," + "        \'is-checked\': isChecked," + "        \'is-indeterminate\': indeterminate," + "        \'is-focus\': focus" + "      }\">" + "      <!-- 隐藏原来的原生checkbox，更改样式 -->" + "      <span class=\"el-checkbox__inner\"></span>" + "      <!-- 有true-label时，显示此插件 -->" + "      <input v-if=\"trueLabel || falseLabel\" class=\"el-checkbox__original\" type=\"checkbox\" :name=\"name\" :disabled=\"disabled\" :true-value=\"trueLabel\" :false-value=\"falseLabel\" v-model=\"model\" @change=\"handleChange\" @focus=\"focus = true\" @blur=\"focus = false\">" + "      <input v-else class=\"el-checkbox__original\" type=\"checkbox\" :disabled=\"disabled\" :value=\"label\" :name=\"name\" v-model=\"model\" @change=\"handleChange\" @focus=\"focus = true\" @blur=\"focus = false\">" + "    </span>" + "    <span class=\"el-checkbox__label\" v-if=\"$slots.default || label\">" + "      <slot></slot>" + "      <template v-if=\"!$slots.default\">{{label}}</template>" + "    </span>" + "  </label>",
			//对外获取的数据
			props: {
				//对外获取的数据
				value: {},
				label: {},
				indeterminate: Boolean,
				disabled: Boolean,
				checked: Boolean,
				name: String,
				trueLabel: [String, Number],
				falseLabel: [String, Number]
			},
			data: function data() {
				//组件内数据部分
				return {
					selfModel: false,
					focus: false
				};
			},
			mounted: function mounted() {
				//组件生成时调用
			},
			methods: {
				addToStore: function addToStore() {
					if(
						//判断当前的模型是否为数组，并且
						Array.isArray(this.model) && this.model.indexOf(this.label) === -1) {
						this.model.push(this.label);
					} else {
						this.model = this.trueLabel || true;
					}
				},
				handleChange: function handleChange(ev) {
					var _this2 = this;

					this.$emit("change", ev);
					if(this.isGroup) {
						this.$nextTick(function(_) {
							_this2.dispatch("ElCheckboxGroup", "change", [_this2._checkboxGroup.value]);
						});
					}
				}
			},
			computed: {
				model: {
					get: function get() {
						return this.isGroup ? this.store : this.value !== undefined ? this.value : this.selfModel;
					},
					set: function set(val) {
						if(this.isGroup) {
							var isLimitExceeded = false;
							this._checkboxGroup.min !== undefined && val.length < this._checkboxGroup.min && (isLimitExceeded = true);

							this._checkboxGroup.max !== undefined && val.length > this._checkboxGroup.max && (isLimitExceeded = true);

							isLimitExceeded === false && this.dispatch("ElCheckboxGroup", "input", [val]);
						} else if(this.value !== undefined) {
							this.$emit("input", val);
						} else {
							this.selfModel = val;
						}
					}
				},

				isChecked: function isChecked() {
					if({}.toString.call(this.model) === "[object Boolean]") {
						return this.model;
					} else if(Array.isArray(this.model)) {
						return this.model.indexOf(this.label) > -1;
					} else if(this.model !== null && this.model !== undefined) {
						return this.model === this.trueLabel;
					}
				},
				isGroup: function isGroup() {
					var parent = this.$parent;
					while(parent) {
						if(parent.$options.componentName !== "ElCheckboxGroup") {
							parent = parent.$parent;
						} else {
							this._checkboxGroup = parent;
							return true;
						}
					}
					return false;
				},
				store: function store() {
					return this._checkboxGroup ? this._checkboxGroup.value : this.value;
				}
			},
			created: function created() {
				this.checked && this.addToStore();
			}
		});

		Vue.component('input-num', {
			template: '<input :type="type" class="form-control" :value="currentValue" @input="handleChange" @blur="blurMoney"/>',
			//对外获取的数据
			props: {
				max: {
					type: Number,
					default: Infinity
				},
				min: {
					type: Number,
					default: -Infinity
				},
				value: {
					type: [Number, String],
					default: ""
				},
				type: {
					type: String,
					default: "text"
				}
			},
			data: function() {
				// Vue组件是单向数据流，无法直接修改prop中的值
				var currentValue = "";
				if(this.value > this.max) {
					currentValue = this.max;
				} else if(this.value < this.min) {
					currentValue = this.min;
				} else {
					currentValue = this.value;
				}
				return {
					currentValue: currentValue
				};
			},
			methods: {
				handleChange: function(event) {
					var val = event.target.value.trim();
					if(val != "") {
						switch(this.type) {
							//正整数
							case "numbers":
								if(isValueNumber(val)) {
									var max = this.max;
									var min = this.min;
									val = Number(val);
									this.currentValue = val;
									if(val > max) this.currentValue = max;
									if(val < min) this.currentValue = min;
								} else {
									event.target.value = this.currentValue;
								}
								break;

							case "money":
								if(isMoney(val)) {
									var max = this.max;
									var min = this.min;
									if(val != '0.0') {
										val = Number(val);
									}
									this.currentValue = val;
									if(val > max) this.currentValue = max;
									if(val < min) this.currentValue = min;
								} else {
									if(val.indexOf(".") != 0 && ((val.indexOf(".") == val.length - 1) || (val == "0.0"))) {
										//判断小数点的情况
										this.currentValue = val;
									}
									if(val.length == 1) {
										this.currentValue = event.target.value = "";
									} else {
										event.target.value = this.currentValue;
									}
								}
								break;
							default:
								break;
						}
					} else {
						this.currentValue = event.target.value = "";
					}
				},
				// 处理失去焦点时最后一位为小数的情况
				blurMoney(event) {
					var val = event.target.value.trim();
					if(this.type == "money") {
						if(val.indexOf(".") != 0 && val.indexOf(".") == val.length - 1) {
							this.currentValue = event.target.value = val.slice(0, val.length - 1)
						}
					}
				}

			},
			watch: {
				currentValue: function(val) {
					this.$emit("input", val);
				},
				value: function() {
					this.currentValue = this.value;
				}
			}
		});

		function isValueNumber(value) {
			return /(^-?[0-9]+\.{1}\d+$)|(^-?[1-9][0-9]*$)|(^-?0{1}$)/.test(value);
		}

		function isMoney(value) {
			return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(
				value
			);
		}